package workQueue;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import utils.RabbitMQUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @version 1.0
 * 功能目的描述 ：用于         ========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-07-28 20:49
 */
//工作线程   相当于以前的 消费者
public class Work01 {
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMQUtils.getChannel();

        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("接收到的消息： " + new String(message.getBody()));
        };

        CancelCallback cancelCallback = (consumerTag) -> {
            System.out.println(consumerTag + " 消费者中断接收消息 回调");
        };

        System.out.println("-----------编号2： 等待接收消息------->>>>>>>>>>>");
        channel.basicConsume(QUEUE_NAME, true, deliverCallback, cancelCallback);
    }
}
